package cn.mofei.spring_aop.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.Configuration;

/**
 * 想要让spring扫描到@Aspect注解，有两种方式：
 * 1.在UserServiceAop上添加注解@Configuration
 * 2.定义configuration,new UserServiceAop
 */
@Aspect
public class UserServiceAop {

    @Around("execution (* cn.mofei.spring_aop.service.UserService.*(..))")
    public Object sayHelloAop(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("before");
        Object obj = pjp.proceed();
        System.out.println("after");
        return obj;
    }
}
